// 引入readline模块
const readline = require('readline');

//创建readline接口实例
const rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
});

// question方法
// rl.question("你的名字是？", function (answer) {
//     console.log("我的名字是：" + answer);
//     // 不加close，则程序不会结束
//     rl.close();
// });


function myQuestion(title){
    return new Promise((resolve, reject)=>{
        if(title === ''){
            reject("空");
        }
        rl.question(title, function (answer) {
            resolve(answer)
        });
    })
}

async function createPackage(){
    let name = await myQuestion("名字")
    let description = await myQuestion("描述")
    let main = await myQuestion("主体")
    console.log(name, description, main)
    rl.close();
}

createPackage();

// close事件监听
rl.on("close", function () {
    console.log("结束");
    // 结束程序
    process.exit(0);
})
